package top.xana.acg.common.view

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.recyclerview.widget.RecyclerView
import com.youth.banner.Banner
import com.youth.banner.adapter.BannerAdapter

/**
 * Created by xana on 2022/3/23 0023
 * Describe: cv4096@qq.com
 */
class SelfBannerView<T, BA : BannerAdapter<T, RecyclerView.ViewHolder>> : Banner<T, BA> {
    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )
    private var startX = 0
    private  var startY:Int = 0
    override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
//        when (ev.action) {
//            MotionEvent.ACTION_DOWN -> {
//                startX = ev.x.toInt()
//                startY = ev.y.toInt()
//                parent.requestDisallowInterceptTouchEvent(true)
//            }
//            MotionEvent.ACTION_MOVE -> {
//                val endX = ev.x.toInt()
//                val endY = ev.y.toInt()
//                val disX = Math.abs(endX - startX)
//                val disY: Int = Math.abs(endY - startY)
//                if (disX > disY) {
//                    parent.requestDisallowInterceptTouchEvent(canScrollHorizontally(startX - endX))
//                } else {
//                    parent.requestDisallowInterceptTouchEvent(canScrollVertically(startY - endY))
//                }
//            }
//            MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> parent.requestDisallowInterceptTouchEvent(
//                false
//            )
//        }
        parent.requestDisallowInterceptTouchEvent(true)
        return super.dispatchTouchEvent(ev)
    }

}